<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="d" uri="http://dgg.net/jsp/jstl/core" %>

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>事业部订单</title>
    <c:import url="../../header.jsp"/>
    <script> var ALLOT_REFUSED = '${ALLOT_REFUSED}';</script>
</head>
<body>
<div class="content-warp">

<div class="dgg-list-top-warp">
    <div class="screen-search" >
        <ul>
            <li>
                <label>客户姓名：</label>
                <input type="text" class="dggui-input dggui-input-normal" id="customerName" name="customerName" placeholder="输入客户姓名" maxlength="50">
            </li>
            <li>
                <label>关键字：</label>
                <input type="text" class="dggui-input dggui-input-large" id="searchKey" name="searchKey" placeholder="订单编号/生产单编号/客户号码" maxlength="50" style="width: 190px;">
            </li>
            <li>
                <button class="dggui-btn searchBtn">搜索</button>
                <button class="dggui-btn dggui-btn-primary" onclick="cleanSearch()">清空条件</button>
            </li>
        </ul>
    </div>
</div>
<div class="list-content">
    <div class="tool-bar">
        <d:hasUrlAuth authCode="RZSC_OPERATION_TRANSFER_ORG">
        <div class="fl">
            <a href="javascript:void(0);" class="dggui-btn" onclick="trunOver();">跨事业部移交</a>
        </div>
        </d:hasUrlAuth>
    </div>
    <div class="table-warp">
        <table class="dggui-table" id="org_order_table"></table>
    </div>
</div>
</div>
<c:import url="/WEB-INF/jsp/footer.jsp"/>
<script type="text/javascript">
    var datatable;
    dggui.use(['table'], function (){
        var table = dggui.table;
        var opt={
            "elem":"#org_order_table",
            "ajax": sysInfo.basePath+"/org_order/org_order_list.do",
            "scrollX": "true",//是否开启横项滚动
            "paging": "true",
            "oneSelectCheck":true,//单选，同时选中复选框
            "fnServerParams": function (aoData) {
                //搜索条件
                aoData = $.extend(aoData, {
                        customerName:$("#customerName").val(),
                        searchKey:$("#searchKey").val()
                    }
                )
                return aoData;
            },
            "aoColumns": [{
                "sClass": "check-th",
                "orderable": false,
                "title": "<input type='checkbox'  class='checkall'>",
                "render": function(data, type, full, meta) {
                    return '<input type="checkbox" class="checkchild" name="checkchild" value="' + data + '">';
                }
            }, {
                'title': '序号',
                "orderable": false,
                "render": function(data, type, full, meta) {
                    return meta.row + 1;
                }
            },
                {
                    'title': '订单来源',
                    'data': "originCode",
                    "orderable": false,
                    "render": function(data, type, row, meta) {
                        return data;
                    }
                },
                {
                    "title": "订单编号",
                    "orderable": false,
                    "data": "orderNo",
                    "render": function (data, type, row, meta) {
                        var htm = "<a href=\"javascript:void(0)\" onclick=\"openBusinessDetail('"+data+"','"+row.orderId+"')\" class=\"dggui-link\">"+data+"</a>"
                        return htm;
                    }
                },
                {
                    'title': '客户',
                    'data': "customerName",
                    "orderable": false,
                    "render": function(data, type, row, meta) {
                        return data;
                    }
                },
                {
                    "title": "签单时间",
                    "orderable": false,
                    "data": "signTime",
                    "render": function (data, type, full, meta) {
                        return data;
                    }
                },
                {
                    'title': '签单商务',
                    'data': "signUserName",
                    "orderable": false,
                    "render": function(data, type, row, meta) {
                        return data;
                    }
                },
                {
                    'title': '签单部门',
                    'data': "signUserOrgName",
                    "orderable": false,
                    "render": function(data, type, row, meta) {
                        return data;
                    }
                },
                {
                    'title': '所属生产事业部',
                    'data': "productOrgName",
                    "orderable": false,
                    "render": function(data, type, row, meta) {
                        return data;
                    }
                }
            ],
            "columnDefs": []
        };
        datatable=table.render(opt);
        $('.searchBtn').click(function (){
            datatable.ajax.reload();
        });

        // 处理dataTable 异常错误信息
        $.fn.dataTable.ext.errMode = 'none';//不抛出异常
        datatable.on( 'error.dt', function ( e, settings, techNote, message ) {
           if(checkEmpty(settings.jqXHR.responseJSON.error)){dggui.dialog.errors(settings.jqXHR.responseJSON.error, 2000);}
        });
    });
function cleanSearch(){
    $("#customerName").val('');
    $("#searchKey").val('');
}

    /**
     * 跨事业部移交
     */
    function trunOver(){
        var checkDate = $('#org_order_table').dataTableExtend('getCheck');
        if(checkDate.length < 1){
            dggui.dialog.errors('请至少选择一条数据！');
            return false;
        }
        if(checkDate.length > 1){
            dggui.dialog.errors('只能选择一条数据！');
            return false;
        }
        var orderId = checkDate[0].orderId;
        trunOverFromOrg(orderId,$('#org_order_table'));
    }
</script>
</body>

</html>